﻿using Axis.Dao.SQL;
using PhuLeBussinessObject.Base;
using PhuLeBussinessObject.Core;
using PhuLeBussinessObject.CProductType;
using PhuLeBussinessObject.Product;
using PhuLeDao.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FWS.Framework.Log;

namespace PhuLeDao.Product
{
    public class CProductDao : CDaoBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ID="1" />
        /// Neu lay theo danh sach thi ko co ID
        /// </param>
        /// <returns></returns>
        public IList<CProduct> GetProduct(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CProduct> list = CallFunctionWithList<CProduct>(CSystemFunction.GetProduct, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// <InputValue UserID="" Session="" Action="INSERT|UPDATE|DELETE" Title="" Summary="" Content="" />
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionProduct(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionProduct, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("ProductType", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ID="1" />
        /// Neu lay theo danh sach thi ko co ID
        /// </param>
        /// <returns></returns>
        public IList<CProduct> GetProductImportTemp(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CProduct> list = CallFunctionWithList<CProduct>(CSystemFunction.GetListImportTemp, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        public IList<CProduct> GetProductFilter(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CProduct> list = CallFunctionWithList<CProduct>(CSystemFunction.GetProductFilter, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        
        /// <summary>
        /// <InputValue UserID="" Session="" Action="INSERT|UPDATE|DELETE" Title="" Summary="" Content="" />
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionTruncateProductImportTemp(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionTruncateProductImportTemp, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("ActionTruncateProduct", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// <InputValue UserID="" Session="" Action="INSERT|UPDATE|DELETE" Title="" Summary="" Content="" />
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionImportProduct(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionProductImport, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("ActionTruncateProduct", ex.Message);
                return null;
            }
        }
    }
}
